package com.dfbz.demo02_继承的小案例;

import com.sun.org.apache.bcel.internal.classfile.Code;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01 {
    public static void main(String[] args) {

        Coder coder=new Coder();
        coder.name="小灰";
        coder.age=30;
        coder.eat();
        coder.sleep();
        coder.code();

        System.out.println("--------------");

        Teacher teacher=new Teacher();
        teacher.name="小红";
        teacher.age=20;
        teacher.eat();
        teacher.sleep();
        teacher.teach();

    }
}

class Person {
    String name;
    int age;

    public void eat() {
        System.out.println("年龄为【" + age + "】岁的【" + name + "】吃饭");
    }

    public void sleep() {
        System.out.println("年龄为【" + age + "】岁的【" + name + "】睡觉");
    }
}

class Coder extends Person{
    public void code(){
        System.out.println("敲代码....");
    }

}
class Teacher extends Person{
    public void teach(){
        System.out.println("上课......");
    }
}
